package com.bitoon.basketdudes.web;

import com.bitoon.basketdudes.web.jpa.*;

import com.opensymphony.xwork2.*;
import java.util.*;
import javax.persistence.*;
import org.apache.log4j.Logger;

public class pruebajpa extends BaseAction {

    private UsuarioLogin usuario;
    private Logger log = Logger.getLogger(pruebajpa.class);
    private Network network;

    public pruebajpa() {
    }

    public String execute() {

        EntityManager em = null;

        try {
            em = emfBasket.createEntityManager(); // checked

            Query q = em.createNamedQuery("UsuarioLogin.findByNickPassword");
            q.setParameter("nick", "tontolaba");
            q.setParameter("password", "6dfa3feb5ac2ed4d509d1298e165b5009d32344d");

            usuario = (UsuarioLogin)q.getSingleResult();

            Network n = em.find(Network.class, 89);
            setNetwork(n);

        } catch (Exception e) {
            log.error("[execute]: " + e);
        } finally {
            try { em.close(); } catch (Exception e) { }
        }

        return SUCCESS;
    }

    public UsuarioLogin getUsuario() {
        return usuario;
    }

    public Network getNetwork() {
        return network;
    }

    public void setNetwork(Network network) {
        this.network = network;
    }

}
